﻿using System;
using System.Configuration;
using System.Data.Entity;

namespace EFUtil.TestApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            Database.SetInitializer<ProductsContext>(
                new ProductInitializer(new EFUtil.Migrations.ModelBasedNewVersionProvider<ProductsContext>()));

            using (var ctx = new ProductsContext(ConfigurationManager.ConnectionStrings["EFUtilConnection"].ConnectionString))
            {
                //ctx.Products.Add(new Product { IsActive = true, ProductName = "Name for 1", ProductNumber = "1" });
                //ctx.Products.Add(new Product { IsActive = true, ProductName = "Name for 2", ProductNumber = "2" });
                //Console.WriteLine("Added 2 products");


                var products = ctx.Products;
                foreach (var product in products)
                {
                    product.Price = new Random().Next(1, 100);
                }
                ctx.SaveChanges();
                Console.WriteLine("Saved");
            }


            Console.ReadKey();
        }
    }
}
